1. Field of the Invention
This invention relates to a portable electronic apparatus such as a smart card (IC card) in which an integrated circuit (IC) chip comprising a writable or rewritable nonvolatile memory, a CPU and the like is embedded and which executes various types of processing based on commands supplied from the outside, a processing unit of the portable electronic apparatus, and a data processing method in the portable electronic apparatus.
2. Description of the Related Art
In recent years, a smart card as a portable electronic apparatus has broadly spread in various fields. For example, the smart card has been used not only as a credit card, a cash card, a prepaid card, a reward card, a commuter pass or the like in payment of commercial transaction but also as an ID card such as an employee card, a membership card or an insurance card in various fields. In the smart card, an IC chip having a CPU, various memories, a communication interface and the like is embedded. In such a smart card, various data used for various use applications are stored in files of various types in a data memory. For example, in the smart card, log data indicating a history of transaction processing by use of the smart card is stored for each data row by using the file in which the data for the unit of the data row (record) is stored.
In general, the smart card executes processing corresponding to a command from an external apparatus while receiving supply of a power from a reader/writer which is the external apparatus. In such a smart card, if the supply of the power from the external apparatus is blocked during the execution of the processing, the processing is forcibly discontinued. For example, in a system which supplies the power from the reader/writer to the smart card set at a predetermined position, when the smart card is extracted from the above predetermined position, the supply of the power is blocked to forcibly discontinue the processing.
If the processing is discontinued during data update processing such as data writing or rewriting, the data is not updated to a correct state, and frequently has a breakdown state. In particular, the smart card of a contactless type is configured to receive the supply of the power from the reader/writer by radio communication. Consequently, in the smart card of the contactless type, the supply of the power is easily blocked during the processing, and there is a high possibility that the above data breakdown might occur. In a case where the data cannot be updated to the correct state, in the conventional smart card, it is judged that the breakdown of the data occurs, whereby a storage region of the data becomes unusable, or the smart card itself is discarded (replaced). However, in a configuration in which when the breakdown of the data occurs owing to a communication defect other than a security attack, the storage region of the data or the smart card itself is discarded, the smart card cannot efficiently be employed.
Moreover, the application of the smart card usually proceeds with a series of processing in accordance with a predetermined command order. Therefore, if an error is detected with respect to a predetermined command during the series of processing, the series of processing have to be performed again from the beginning. That is, when the error with respect to the predetermined command is detected during the series of processing, a processing efficiency is poor.
For example, a technology disclosed in Jpn. Pat. Appln. KOKAI Publication No. 2007-257542 is a technology which stores the upper limit value of the number of processing times to limit the number of the processing times. Even with the technology disclosed in Jpn. Pat. Appln. KOKAI Publication No. 2007-257542, it is difficult to improve the above poor processing efficiency.